package com.wms.service.impl;

import com.wms.dao.ColorDao;
import com.wms.dao.SizeDao;
import com.wms.model.PageBean;
import com.wms.model.Size;
import com.wms.service.SizeService;
import com.wms.utils.CommonUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.io.Serializable;
import java.util.List;

/**
 * @author This
 * @version 1.0
 * @date 2019/7/25 21:29
 */
@Service
@Transactional
public class SizeServiceImpl extends BaseServiceImpl<Size> implements SizeService {

    @Autowired
    private SizeDao dao;

    @Override
    public boolean add(Size size) {
        List<Size> list = dao.findByCondition("sizeName=?", size.getSizeName());
        if (CommonUtils.isEmpty(list)) {
            dao.save(size);
            return true;
        }
        return false;
    }

    @Override
    public void delete(Size size) {
        dao.delete(size);
    }

    @Override
    public void edit(Size size) {

    }

    @Override
    public Size find(Serializable id) {
        return null;
    }

    @Override
    public void deleteAll(String ids) {
        ids = " id in ( " + ids + " )";
        dao.deleteAll(ids);
    }

    @Override
    public void pageQuery(PageBean<Size> pb) {
        try {
            dao.pageQuery(pb);
        } catch (Exception e) {
        }
    }

    @Override
    public List<Size> findAll() {
        return dao.findAll();
    }
}
